home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / KROSS.ICN < prev    next >
Text File  |  1992-11-26  |  937b  |  39 lines

  1. ############################################################################
  2. #
  3. #    File:     kross.icn
  4. #
  5. #    Subject:  Program to show intersections of strings
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 9, 1989
  10. #
  11. ###########################################################################
  12. #
  13. #     This program procedure accepts pairs of strings on successive lines.
  14. #  It diagrams all the intersections of the two strings in a common
  15. #  character.
  16. #
  17. ############################################################################
  18.  
  19. procedure main()
  20.    local line, j
  21.    while line := read() do {
  22.       kross(line,read())
  23.       }
  24. end
  25.  
  26. procedure kross(s1,s2)
  27.    local j, k
  28.    every j := upto(s2,s1) do
  29.       every k := upto(s1[j],s2) do
  30.          xprint(s1,s2,j,k)
  31. end
  32.  
  33. procedure xprint(s1,s2,j,k)
  34.    write()
  35.    every write(right(s2[1 to k-1],j))
  36.    write(s1)
  37.    every write(right(s2[k+1 to *s2],j))
  38. end
  39.